package com.kamkor.interviewer.server;

import java.util.Random;

public class Utils {
	private static Random random = new Random();
	
	public static Long generateAdminKey(final Interview interview) {		
		final String interviewerName = interview.getInterviewerName();
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((interviewerName == null) ? 0 : interviewerName.hashCode());
		result += random.nextInt(100) * random.nextInt(100);
		return new Long(Math.abs(result));
	}
	
	public static Long generateUserKey(final Interview interview) {
		final String interviewedName = interview.getInterviewedName();
		final int prime = 31;
		int result = 1;		
		result = prime * result
				+ ((interviewedName == null) ? 0 : interviewedName.hashCode());	
		result += random.nextInt(100) * random.nextInt(100);
		return new Long(Math.abs(result));
	}
}
